<?php

/**
 * Project: CrazyPoems
 * Author: Alexandru
 * Date: 29/10/2008
 * File: functions.admin.php
 */

function Hop_newCategory($name) {
	$q = mysql_query("INSERT INTO ".TABLE_CATEGORIES."(name) VALUES('".checkSQL($name)."')") or die(mysql_error());
}

function Hop_editCategory($categoryId, $name) {
	$q = mysql_query("UPDATE ".TABLE_CATEGORIES." SET name = '".checkSQL($name)."' WHERE id = $categoryId") or die(mysql_error());
}

function Hop_deleteCategory($categoryId) {
	// Update poems from this category to category 0.
	$q2 = mysql_query("UPDATE ".TABLE_POEMS." SET category = 0 WHERE category = $categoryId") or die(mysql_error());
	// Delete this category.
	$q = mysql_query("DELETE FROM ".TABLE_CATEGORIES." WHERE id = $categoryId") or die(mysql_error());
}
?>
